package service;

import dao.ChoiceDao;
import entity.Choice;
import entity.ServiceTime;

import java.util.List;

public class ChoiceService {
    ChoiceDao choiceDao=new ChoiceDao();

    public List<Choice> getChoice(String sql,String shopId,String catId) {
        List<Choice> choiceList= choiceDao.getChoice(sql, shopId);
        String sql2="SELECT * FROM servicetime WHERE choiceId=? AND catId=?";
        // 根据套餐id和品种猫id查询当前套餐的所有服务时间
        for(Choice c:choiceList){
            List<ServiceTime> serviceTimeList=choiceDao.getServiceTime(sql2,c.getId(),catId);
            // 将查询到的服务时间放入当前套餐中
            c.setServiceTimeList(serviceTimeList);
        }
        return choiceList;
    }
}
